home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / DO1002.ARJ / DATES.SCR < prev    next >
Text File  |  1991-12-31  |  5KB  |  157 lines

  1. .pg wi full clr
  2. /STOP End
  3. /GOSUB DrawCalendar
  4. .go 1 17
  5.     »%t«DO»#« has a set of functions to handle dates and times.  These
  6.     functions allow you to do date and time math and display date and
  7.     time strings and the day of the week.
  8.  
  9. .go 1 25
  10. »bo«Press any key to continue . . .»#«&
  11. .wi 10 10 80 25 gr
  12. :ShowClock
  13. .go 1 1
  14. /big {time}
  15. /INKEY "" DateTime2
  16. /GOTO ShowClock
  17. :DateTime2
  18. /GOSUB DrawCalendar
  19. /CLOCK ON 12 19
  20. .wi 32 10 80 25
  21. »%t«DATE»#« Converts a date string to a number
  22.      of days
  23.  
  24. »%t«TIME»#« Converts a time string to a number
  25.      of seconds
  26.  
  27. »%t«DTST»#« Converts a number of days to a date
  28.      string
  29.  
  30. »%t«TMST»#« Converts a number of seconds
  31.      to a time string
  32.  
  33. »%t«DAY»#«  Returns day of the week
  34. .pg -25
  35. /CLOCK OFF
  36. .wi full clr cy
  37.     FUNCTION NAME»gray«: »%t« Date »cy«
  38.  
  39.     ~064date({DateString})
  40. /cw
  41.     Date converts »cy«{DateString}»#« to a number of »wh«days since 1/1/1901»#«.
  42.     »cy«{DateString}»#« can be in any one of a number of formats:
  43.  
  44.         »ye«MM/DD/YY»#«               "12/01/91" or "3/5/91"
  45.         »ye«"Month Day, Year"»#«      "September 6, 1991" or
  46.                                "Dec 7, 1991" or
  47.                                "Dec. 7, 1991"
  48.                                »gr«NOTE»wh«:»#« if you use this extended
  49.                                      format you »re«MUST»#« enclose the
  50.                                      date in quote marks.
  51.         »ye«~123date~125»#«                 Special variable which returns today's
  52.                                date.
  53.  
  54. .pg clr
  55.     Here are some examples.  Press »bo«<enter>»#« to execute each line.
  56.  
  57. |    Today is @date({date})
  58. |    The date is @date(12/01/91)
  59. |    The date is also @date("December 1, 1991")
  60. /SET Default ""
  61. :DateExample
  62. /GETS Date Default "    Enter a Date (»bo«<enter>»#« to stop):"
  63. /IF %Date NE "" DateExample2
  64.     The date %Date converted to days is: @date(%date)
  65. /GOTO DateExample
  66. :DateExample2
  67. .pg wi full clr cy
  68.     FUNCTION NAME»gray«: »%t« Time »cy«
  69.  
  70.     ~064time({TimeString})
  71. /cw
  72.  
  73.     Converts »cy«{TimeString}»#« into a number of »wh«seconds since
  74.     midnight»#«. »cy«{TimeString}»#« can use »ye«24-hour time»#« (military time)
  75.     or "»ye«a.m./p.m.»#«" notation.  It is in the format:
  76. »ma«
  77.         HH:MM[:SS] [a.m.|p.m.]
  78. »#«
  79.     It can also interpret the special variable »gr«~123time~125»#« which
  80.     represents the current time on your computer.
  81.  
  82. .pg
  83.     Here are some examples.  Press »bo«<enter>»#« to execute each.
  84.  
  85. |    The current time {time} = @time({time}) minutes since midnight
  86. |    Time = @time(11:10)
  87. |    Time = @time(13:23:00)
  88. |    Time = @time('1:23 pm')
  89. .pg wi full clr cy
  90.     FUNCTION NAME»gray«: »%t« DateString »cy«
  91.  
  92.     ~064dtst({Days})
  93. /cw
  94.  
  95.     Converts a number of »wh«days since January 1, 1901»#« into a date
  96.     string in the format "»ye«MM/DD/YY»#«". »%t«DateString»#« can also handle
  97.     »wh«math calculations»#«.
  98.  
  99.     Here are some examples.  Press »bo«<enter>»#« to execute each one.
  100.  
  101. |/SET Date @date({date})
  102. |    @dtst(%date) is %date days since 1/1/1901.
  103. |    Tomorrow is @dtst(@date({date})+1)
  104. .pg wi full clr cy
  105.     FUNCTION NAME»gray«: »%t« TimeString »cy«
  106.  
  107.     ~064tmst({seconds})
  108. /cw
  109.     Converts a number representing »wh«seconds since midnight»#« into a
  110.     time string in the format "»ye«HH:MM:SS»#«" (»cy«24-hour time»#«).
  111.     »%t«TimeString»#« can also handle »wh«math functions»#«.
  112.  
  113.     Here are some examples.  Press »bo«<enter>»#« to execute each one.
  114.  
  115. |/SET Time @time({time})
  116. |    It is now %time seconds since midnight or @tmst(%time)
  117. |/SET Time @time('3:35 pm')
  118. |    3:35 pm (%time seconds) + 60 minutes is @tmst(%time+(60*60))
  119.     Note that calculations have to be in »wh«SECONDS»#«.
  120. .pg wi full clr cy
  121.     FUNCTION NAME»gray«: »%t« DayOfWeek »cy«
  122.  
  123.     ~064day({DateString})
  124. /cw
  125.  
  126.     Returns the three character day of the week for »cy«{DateString}»#«.
  127.  
  128.     Here are some examples.  Press »bo«<enter>»#« to execute each.
  129.  
  130. |    Today ({date}) is »gr«@day({date})»#«
  131. |    Tomorrow is         »gr«@day(@dtst(@date({date})+1))»#«
  132.     The other days are  »gr«@day(@dtst(@date({date})+2))»#«
  133.                         »gr«@day(@dtst(@date({date})+3))»#«
  134.                         »gr«@day(@dtst(@date({date})+4))»#«
  135.                         »gr«@day(@dtst(@date({date})+5))»#«
  136.                         »gr«@day(@dtst(@date({date})+6))»#«
  137. /GOTO End
  138. :DrawCalendar
  139. .wi full clr wh
  140. ┌───┬───┬───┬───┬───┬───┬───┐
  141. │»ma«Sun»wh«│»ma«Mon»wh«│»ma«Tue»wh«│»ma«Wed»wh«│»ma«Thu»wh«│»ma«Fri»wh«│»ma«Sat»wh«│
  142. ╞═══╪═══╪═══╪═══╪═══╪═══╪═══╡»ye« ╥─┐ ╓─╖ ╓╥╖ ╥─╖  ╓─╖ ╖ ╖ ╥─┐  ╓╥╖ ╥ ╥╥╖ ╥─╖»wh«
  143. │   │  1│  2│  3│  4│  5│  6│»ye« ║ │ ╟─╢  ║  ╟─   ╟─╢ ║\║ ║ │   ║  ║ ║║║ ╟─ »wh«
  144. ├───┼───┼───┼───┼───┼───┼───┤»ye« ╨─┘ ╙ ╙  ╙  ╨─╜  ╙ ╙ ╙ ╙ ╨─┘   ╙  ╨ ╙╙╙ ╨─╜»wh«
  145. │  7│  8│  9│ 10│ 11│ 12│ 13│»ye« ╥─╖ ╖ ╖ ╖ ╖ ╓─╖ ╓╥╖ ╥ ╓─╖ ╖ ╖ ╓─╖»wh«
  146. ├───┼───┼───┼───┼───┼───┼───┤»ye« ╟─  ║ ║ ║\║ ║    ║  ║ ║ ║ ║\║ ╙─╖»wh«
  147. │ 14│ 15│ 16│ 17│ 18│ 19│ 20│»ye« ╙   ╙─╜ ╙ ╙ ╙─╜  ╙  ╨ ╙─╜ ╙ ╙ ╙─╜»wh«
  148. ├───┼───┼───┼───┼───┼───┼───┤
  149. │ 21│ 22│ 23│ 24│ 25│ 26│ 27│
  150. ├───┼───┼───┼───┼───┼───┼───┤
  151. │ 28│ 29│ 30│ 31│   │   │   │
  152. └───┴───┴───┴───┴───┴───┴───┘»#«
  153. /RETURN
  154. :End
  155. /CLOCK OFF
  156. /ENDEXEC CLEAR
  157.